<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="javatime" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href=<%=basePath%>
          <%@include file="../common_css.jsp"%>
                  </head>
<body class="childrenBody">
<form class="layui-form" style="width:80%;">
    <input type="hidden" name="carId" value="${cancelApply.car.id}">
    <input type="hidden" name="cusId" value="${cancelApply.customer.id}">
    <input type="hidden" name="userId" value="${cancelApply.customer.user.id}">
    <input type="hidden" name="orderId" value="${cancelApply.cusOrder.id}">
    <div class="layui-form-item layui-row">
        <div class="layui-col-xs6">
            <label class="layui-form-label">订单编号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="required" name="order_id" id="order_id"  value="${cancelApply.cusOrder.orderId}"
                       readonly
                >
            </div>
        </div>
        <div class="layui-col-xs6">
            <label class="layui-form-label">客户姓名</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="required" name="customerName" id="customerName"  value="${cancelApply.customer.name}"
                       readonly
                >
            </div>
        </div>
    </div>


    <div class="layui-form-item layui-row">
        <div class="layui-col-xs6">
            <label class="layui-form-label">车型</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       name="car" id="car"  value="${cancelApply.car.series} ${cancelApply.car.model}"
                       readonly
                >
            </div>
        </div>
        <div class="layui-col-xs6">
            <label class="layui-form-label">员工姓名</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                        name="user" id="user"  value="${cancelApply.customer.user.name}"
                       readonly
                >
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-row">
        <div class="layui-col-xs6">
            <label class="layui-form-label">退款金额</label>
            <div class="layui-input-block">
            <input type="text" class="layui-input" id="price" name="price"
                   value="5000"
                   readonly
            >
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-row">
        <label class="layui-form-label">退订原因</label>
        <div class="layui-input-block">
            <textarea  name="cause" id="cause" class="layui-textarea" lay-verify="required"></textarea>
        </div>
    </div>

    <br/>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-lg" lay-submit=""
                    lay-filter="saveCancelApply">确认
            </button>
            <button class="layui-btn layui-btn-lg layui-btn-normal">取消</button>
        </div>
    </div>

</form>
<script type="text/javascript">
    layui.use(['form', 'layer','laydate'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;


        form.on('submit(saveCancelApply)',function (data) {
            var index= top.layer.msg("数据提交中,请稍后...",{icon:16,time:false,shade:0.8});
            $.ajax({
                url:"cancelApply/saveCancelApply",
                type:"post",
                data:{
                    carId:$("[name=carId]").val(),
                    cusId:$("[name=cusId]").val(),
                    userId:$("[name=userId]").val(),
                    orderId:$("[name=orderId]").val(),
                    price:$("[name=price]").val(),
                    cause:$("[name=cause]").val()
                },
                success:function (res){
                    if(res=='success'){
                        top.layer.msg("操作成功");
                        top.layer.close(index);
                        layer.closeAll("iframe");
                        // 刷新父页面
                        parent.location.reload();
                    }
                }
            })
            return false;
        });
        // $.post("/customer/findCustomerByState",{state:2},function (res) {
        //     for(var i=0;i<res.length;i++){
        //         if($("input[name='inputCusId']").val() == res[i].id){
        //             $("#cusId").append("<option value=\""+res[i].id+"\"  selected >"+res[i].name+"</option>")
        //         }else{
        //             $("#cusId").append("<option value=\""+res[i].id+"\"   >"+res[i].name+"</option>")
        //         }
        //     }
        //     layui.form.render("select");
        // });
        // $.post("/car/findCarAll",function (res) {
        //     for(var i=0;i<res.length;i++){
        //         if($("input[name='inputCarId']").val() == res[i].id){
        //             $("#carId").append("<option value=\""+res[i].id+"\" selected  >"+res[i].series+" "+res[i].model+"</option>");
        //         }else{
        //             $("#carId").append("<option value=\""+res[i].id+"\"   >"+res[i].series+" "+res[i].model+"</option>");
        //         }
        //     }
        //     layui.form.render("select");
        // });
        // $.post("/dictionaries/findDriveType",function (res) {
        //     for(var i=0;i<res.length;i++){
        //         if($("input[name='inputDriveType']").val() == res[i].valueId){
        //             $("#driveType").append("<option value=\""+res[i].valueId+"\" selected  >"+res[i].valueName+"</option>");
        //         }else{
        //             $("#driveType").append("<option value=\""+res[i].valueId+"\"   >"+res[i].valueName+"</option>");
        //         }
        //
        //     }
        //     layui.form.render("select");
        // });
        //
        //
        // if($("input[name='inputUserId']").val()!=''){
        //     $.post("/user/findUser",function (res) {
        //         console.log("!!!!")
        //         console.log(res)
        //         for(var i=0;i<res.length;i++) {
        //             if ($("input[name='inputUserId']").val() == res[i].id) {
        //                 $("#userId").append("<option value=\"" + res[i].id + "\" selected  >" + res[i].name + "</option>");
        //             } else {
        //                 $("#userId").append("<option value=\"" + res[i].id + "\"   >" + res[i].name + "</option>");
        //             }
        //         }
        //         layui.form.render("select");
        //     })
        // }
        //
        // form.on('select(cusId)', function(data){
        //     $.post("/user/findUserByCustomerId",{cusId:data.value},function (data) {
        //         $("#userId").append("<option value=\""+data.id+"\" selected  >"+data.name+"</option>");
        //         layui.form.render("select");
        //     })
        // });
        //
        // form.on('checkbox(primary)', function(data){
        //     if (data.elem.checked==true){
        //         $("#driveName").attr("disabled","disabled");
        //         $("#driveName").val($("#cusId option:selected").text())
        //     }else {
        //         $("#driveName").removeAttr("disabled");
        //         $("#driveName").val("");
        //     }
        // });
    });
</script>
</body>
</html>